package com.woniuxy.homepage.core.controller;


import com.woniuxy.common.CommonResult;
import com.woniuxy.homepage.core.model.CarType;
import com.woniuxy.homepage.core.service.CarTypeService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author gmx
 * @since 2021-06-29
 */
@RestController
@RequestMapping("/carType")
@Api(tags = "车系接口")
public class CarTypeController {

    @Resource
    private CarTypeService carTypeService;


    /**
     * Description : 查询车系  <br/>
     * ChangeLog : 1. 创建 (2021/7/1 11:12 [Hello Mr. Guo]);
     * @param brandId
     * @return com.woniuxy.common.CommonResult
    */
    @ApiOperation("查询车系")
    @GetMapping("/selectByBrandId/{brandId}")
    public CommonResult selectByBrandId(@PathVariable("brandId")Integer brandId){
        List<CarType> list = this.carTypeService.selectByBrandId(brandId);
        if (list == null){
            return CommonResult.fail("查询车系失败");
        }
        return CommonResult.success(list);
    }

}

